
import React, { Component } from 'react';
import { Menu, Icon, Layout, Badge, Popover, message, Modal, Dropdown,Breadcrumb } from 'antd';
import screenfull from 'screenfull';
// import { gitOauthToken, gitOauthInfo } from '../axios';
import { queryString } from '../../utils';
import avater from '../../style/imgs/b1.jpg';
import SiderCustom from '../SiderCustom/SiderCustom';
import { connect } from 'react-redux';
import { Router, Route, hashHistory, IndexRedirect, browserHistory, IndexRoute } from 'react-router';
import ERPfetch from '../../utils/Fetch/ERPfetch';
import Mutil from '../../utils/mm'
import MutilsCookie from '../../utils/cookie'
import './header.less'

const confirm = Modal.confirm;
// 弹框内容

// 引入存储封装文件
// var __mm = new Mutil();
const { Header } = Layout;
const SubMenu = Menu.SubMenu;
const MenuItemGroup = Menu.ItemGroup;


class HeaderCustom extends Component {
    constructor(props) {
        super(props);
        // this.logout = this.logout.bind(this)
        this.showConfirm = this.showConfirm.bind(this)
        this.toggle = this.toggle.bind(this)
        this.changePassword = this.changePassword.bind(this)
    }
    state = {
        user: '',
        // visible: false,
        // 取出信息
        realName:Mutil.getStorage('userInfo').realName,//用户真实名字
        token:Mutil.getStorage('userInfo').token,//获取token值
        tokenCookie:MutilsCookie.get('userInfo'),//获取token值
        visible: false,//弹框出现
        //collapsed: false,//左边收放
    };
    componentDidMount() {
        // console.log(this.state.realName)
        const QueryString = queryString();
    };
    screenFull = () => {
        if (screenfull.enabled) {
            screenfull.request();
        }

    };
    //退出登录 
    showConfirm = () => {
        const that = this;
        // let token = this.state.token
        Modal.confirm({
            title: '亲：确定要退出吗?',
            onOk() {
                that.props.logoutAction();// 退出登录(调取主组件的方法)
            },
            onCancel() { },
        });
    };
    // menuClick = e => {
    //     console.log(e);
    //     e.key === 'logout' && this.logout();
    // };
    // 修改密码
    changePassword = () => {
        // console.log("修改密码")
        browserHistory.push('/app/changePassWord')
    }

    popoverHide = () => {
        this.setState({
            visible: false,
        });
    };
    handleVisibleChange = (visible) => {
        this.setState({ visible });
    };
    // 向左收放
    toggle = () => {
        // this.setState({
        //     collapsed: !this.state.collapsed,
        // });
        this.props.onToggle()
        // console.log("111")
    }
    render() {
        const { responsive, path } = this.props;
        console.log(path)
        // 下拉菜单
        // const menu = (
        //     <Menu>
        //         <Menu.Item>
        //             <a rel="noopener noreferrer" style={{textAlign:"center",fontSize:"14px"}} onClick={this.changePassword}>修改密码</a>
        //         </Menu.Item>
        //         <Menu.Item>
        //             <a onClick={this.showConfirm} style={{ textAlign:"center",fontSize:"14px"}}>退出登录</a>
        //         </Menu.Item>
        //     </Menu>
        // );
        return (
            <Header style={{ background: '#fff'}} className="custom-theme" >
                <div className={'breadcrumb_wrap'}>
                    <Breadcrumb>
                        <Breadcrumb.Item href={'/'}>预售管理</Breadcrumb.Item>
                        <Breadcrumb.Item style={{fontSize:18,color:'#000'}}>{path.name}</Breadcrumb.Item>
                    </Breadcrumb>
                </div>

                    <div className="select_menu">

                    </div>
            </Header>
        )
    }
}

const mapStateToProps = state => {
    const { responsive = { data: {} } } = state.httpData;
    return { responsive };
};

export default connect(mapStateToProps)(HeaderCustom);
